package com.sanpu.kxe.business.trade.provider;

import android.content.Context;
import android.content.Intent;

import com.sanpu.kxe.business.trade.bean.PayCollectionOutput;
import com.sanpu.kxe.business.trade.bean.PayOrderOutput;
import com.sanpu.kxe.business.trade.bean.PaymentOutput;
import com.sanpu.kxe.business.trade.bean.SupportBankOutput;
import com.sanpu.kxe.business.trade.contract.TradeConfig;
import com.sanpu.kxe.business.trade.model.TradeModel;
import com.sanpu.kxe.business.trade.view.MyProfitActivity;
import com.sanpu.kxe.business.trade.view.MyRebTotalActivity;
import com.sanpu.kxe.business.trade.view.PaymentQRcodeActivity;
import com.sanpu.kxe.business.trade.view.RebTotalListActivity;
import com.sanpu.kxe.business.trade.view.TransactionActivity;
import com.sanpu.kxe.business.trade.view.WithdrawActivity;
import com.sanpu.kxe.common.enums.PayType;
import com.sanpu.kxe.utils.IntentTool;

import java.math.BigDecimal;
import java.util.List;

import rx.Observable;

/**
 * Description：交易模块对外接口实现类
 * Created by 薛勇军 on 2018/8/1.
 */

public class TradeProvider implements ITradeProvider {

    @Override
    public void openPaymentQRcodeActivity(Context context, String vipOpenId, PayType payType,
                                          String reqAmount, String appCnlConfId) {
        Intent intent = new Intent(context, PaymentQRcodeActivity.class);
        intent.putExtra(TradeConfig.INTENT_VIPOPENID, vipOpenId);
        intent.putExtra(TradeConfig.INTENT_PAYTYPE, payType);
        intent.putExtra(TradeConfig.INTENT_AMOUNT, reqAmount);
        intent.putExtra(TradeConfig.INTENT_RLID, appCnlConfId);
        IntentTool.startActivity(context, intent);
    }

    @Override
    public void openTransactionActivity(Context context) {
        IntentTool.startActivity(context, TransactionActivity.class);
    }

    @Override
    public void openMyRebTotalActivity(Context context, int currentItem) {
        Intent intent = new Intent(context, MyRebTotalActivity.class);
        intent.putExtra(TradeConfig.INTENT_CURRENT_ITEM, currentItem);
        IntentTool.startActivity(context, intent);
    }

    @Override
    public void openWithdrawActivity(Context context, String withdrawMoney) {
        Intent intent = new Intent(context, WithdrawActivity.class);
        intent.putExtra(TradeConfig.INTENT_AMOUNT, withdrawMoney);
        IntentTool.startActivity(context, intent);
    }

    @Override
    public void openChargerTelFeeActivity(Context context) {
        TradeOpenProvider.getInstance().openChargerTelFeeActivity(context);
    }

    @Override
    public Observable<PaymentOutput> userPayment(
            String payAmount, String payType, String constype, String pkgId, String phoneNo) {
        return TradeModel.getInstance().userPayment(payAmount, payType, constype, pkgId, phoneNo);
    }

    @Override
    public Observable<PayOrderOutput> payOrder(String amount, String appCnlConfId, String vipOpenId) {
        return TradeModel.getInstance().payOrder(amount, appCnlConfId, vipOpenId);
    }

    @Override
    public Observable<PayOrderOutput> payOrder(BigDecimal amount, String appCnlConfId, String outTradeNo) {
        return TradeModel.getInstance().payOrder(amount, appCnlConfId, outTradeNo);
    }

    @Override
    public Observable<List<PayCollectionOutput>> appCnlConfList(String receivablesType, String mercCardId, String version) {
        return TradeModel.getInstance().appCnlConfList(receivablesType, mercCardId, version);
    }

    @Override
    public void openGatheringActivity(Context context, boolean isPersonal) {
        TradeOpenProvider.getInstance().openGatheringActivity(context, isPersonal);
    }

    @Override
    public void openRebTotalListActivity(Context context) {
        IntentTool.startActivity(context, new Intent(context, RebTotalListActivity.class));
    }

    @Override
    public void openQuickPayWebViewActivity(Context context, String webUrl, String postData) {
        TradeOpenProvider.getInstance().openQuickPayWebViewActivity(context, webUrl, postData);
    }

    @Override
    public Observable<List<SupportBankOutput>> findAppCnlConfBankSupportDetailList(String appCnlConfId) {
        return TradeModel.getInstance().appBaseBank(appCnlConfId);
    }

    @Override
    public void openMyProfitActivity(Context context) {
        IntentTool.startActivity(context, new Intent(context, MyProfitActivity.class));
    }
}
